package web.Courts;

import com.google.gson.Gson;
import entity.CourtsBean;
import entity.UserBean;
import services.CourtsServiceAll;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;

@WebServlet("/getCourtsByName")
public class GetCourtsByName extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        resp.setContentType("application/json");
        String court_table = req.getParameter("court_table");
        // 模糊查询
        List<CourtsBean> courtsByTable = new CourtsServiceAll().getCourtsByName(court_table);
        Gson gson = new Gson();
        String json = gson.toJson(courtsByTable);
        resp.getWriter().println(json);
    }
}
